import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import "./assets/fonts/iconfont.css"; //导入阿里图标
//引入饿了么
import installElementPlus from "./plugins/element"; //饿了么的引入要放在vue的引入后面
import "element-plus/lib/theme-chalk/index.css";
import * as ElIcons from "@element-plus/icons";
import "./assets/css/global.css"; //导入全局样式表
import utils from "./assets/js/utils.js"; //导入通用方法
// import * as echarts from "echarts"; //在需要用的页面引入，不在这里引入
// import TreeTable from "vue-table-with-tree-grid"; //导入属性表格,目前只支持Vue2.0,不好用

const app = createApp(App);
//#region 配置全局axios
// //Vue2.x配置全局axios
// //引入全局axios,this.$http.post('login',this.loginForm)即可发起网络请求
// import Vue from "vue";
// import axios from "axios";
// axios.defaults.baseURL = "http://localhost:30214/api";
// axios.defaults.timeout = 5000;
// Vue.prototype.$http = axios;

// //Vue3.x配置全局axios
// import axios from "axios";
// axios.defaults.baseURL = "http://localhost:30214/api";
// axios.defaults.timeout = 5000;
// //为请求头对象,添加Token验证的Authorization字段
// axios.interceptors.request.use(config=>{
//     config.headers.Authorization=window.sessionStorage.getItem('')
// })
// app.config.globalProperties.$http = axios;
//#endregion

installElementPlus(app); //挂载Element-ui
app.config.globalProperties.$utils = utils; //注册全局通用方法
// app.config.globalProperties.$echarts = echarts; //注册全局echarts,不注册
//注册全局过滤器
app.config.globalProperties.$filters = {
  dateFormat(originVal) {
    const dt = new Date(originVal);
    const y = dt.getFullYear();
    const m = (dt.getMonth() + 1 + "").padStart(2, "0");
    const d = (dt.getDate() + "").padStart(2, "0");

    const hh = (dt.getHours() + "").padStart(2, "0");
    const mm = (dt.getMinutes() + "").padStart(2, "0");
    const ss = (dt.getSeconds() + "").padStart(2, "0");

    return `${y}-${m}-${d} ${hh}-${mm}-${ss}`;
  }
};

Object.keys(ElIcons).forEach(key => {
  app.component(key, ElIcons[key]);
});
// app.component("tree-table", TreeTable);
app.use(router).mount("#app");
